package com.xuan.singleton.lazy;

public class Singleton4 {
    private Singleton4(){}

    private static Singleton4 instance;

    /**
     * 懒汉式单例 - 双重检查锁
     * @return
     */
    public static Singleton4 getInstance() {
        if (instance == null) {
            synchronized (Singleton4.class) {
                if (instance == null) {
                    instance = new Singleton4();
                }
            }
        }
        return instance;
    }
}
